<style>
    #message_edit_form .col-sm-1 label {
        font-size: 12px;
        width: 100%;
        text-align: center;
    }

    #message_edit_form .col-sm-1 {
        padding: 0 7px;
    }

    #message_edit_form .modal-body div:first-child {
        background-color: #8abe8f;
        padding-bottom: 7px;
    }
</style>
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title">报文信息新增</h4>
</div>
<form id="message_edit_form" method="post" class="form-horizontal">
    <div class="modal-body">
        <div class="form-group">
            <input type="hidden" name="id" th:value="${equipmentMessageConf==null?'':equipmentMessageConf.id}">
            <input type="hidden" name="equipment_id" th:value="${equipment_id}">
            <div class="col-sm-1">
                <label class="control-label" style="text-align:center">科目名称</label>
                <input type="text" class="form-control" name="subjectName"
                       th:value="${equipmentMessageConf==null?'':equipmentMessageConf.subjectName}"/>
            </div>
            <div class="col-sm-1">
                <label class="control-label" style="text-align:center">CAN_ID</label>
                <input type="text" class="form-control" name="canId"
                       th:value="${equipmentMessageConf==null?'':equipmentMessageConf.canId}"/>
            </div>
            <div class="col-sm-1">
                <label class="control-label" style="text-align:center">CAN数据长</label>
                <input type="number" class="form-control" name="canLong"
                       th:value="${equipmentMessageConf==null?'':equipmentMessageConf.canLong}"/>
            </div>
            <div class="col-sm-1">
                <label class="control-label" style="text-align:center">大小头</label>
                <input type="text" class="form-control" name="head"
                       th:value="${equipmentMessageConf==null?'':equipmentMessageConf.head}"/>
            </div>
            <div class="col-sm-1">
                <label class="control-label" style="text-align:center">数据类型</label>
                <input type="text" class="form-control" name="dataType"
                       th:value="${equipmentMessageConf==null?'':equipmentMessageConf.dataType}"/>
            </div>
            <div class="col-sm-1">
                <label class="control-label" style="text-align:center">起始字节</label>
                <input type="number" class="form-control" name="beginByte"
                       th:value="${equipmentMessageConf==null?'':equipmentMessageConf.beginByte}"/>
            </div>
            <div class="col-sm-1">
                <label class="control-label" style="text-align:center">起始位</label>
                <input type="number" class="form-control" name="beginPosition"
                       th:value="${equipmentMessageConf==null?'':equipmentMessageConf.beginPosition}"/>
            </div>
            <div class="col-sm-1">
                <label class="control-label" style="text-align:center">结束字节</label>
                <input type="number" class="form-control" name="endByte"
                       th:value="${equipmentMessageConf==null?'':equipmentMessageConf.endByte}"/>
            </div>
            <div class="col-sm-1">
                <label class="control-label" style="text-align:center">结束位</label>
                <input type="number" class="form-control" name="endPosition"
                       th:value="${equipmentMessageConf==null?'':equipmentMessageConf.endPosition}"/>
            </div>
            <div class="col-sm-1">
                <label class="control-label" style="text-align:center">偏移量</label>
                <input type="number" class="form-control" name="offset"
                       th:value="${equipmentMessageConf==null?'':equipmentMessageConf.offset}"/>
            </div>
            <div class="col-sm-1">
                <label class="control-label" style="text-align:center">倍率</label>
                <input type="text" class="form-control" name="multiple"
                       th:value="${equipmentMessageConf==null?'':equipmentMessageConf.multiple}"
                       onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9.]+/,'');}).call(this)" onblur="this.v();" />
            </div>
            <div class="col-sm-1">
                <label class="control-label" style="text-align:center">单位</label>
                <input type="text" class="form-control" name="unit"
                       th:value="${equipmentMessageConf==null?'':equipmentMessageConf.unit}"/>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label" style="float:left; padding:0 10px; line-height: 34px;">对应平台编号</label>
            <input type="text" class="form-control" name="objId" style="width: 200px"
                   th:value="${equipmentMessageConf==null?'':equipmentMessageConf.objId}"/>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" onclick="save_form('message_edit_form')">保存</button>
    </div>
</form>
<script>
    function save_form(id) {
        var form = $("#"+id);
        $.post(
            'save_message',
            $(form).serialize(),
            function (result) {
                alert(result.message);
                $("#dataTable1").bootstrapTable('destroy');
                init_list_table();
                $(form).prev().find("button").click();
            }
        )
    }
</script>